package net.zoneland.zrdp.framework.manager;

import net.zoneland.zrdp.common.utils.spring.SpringUtils;

import org.springframework.core.task.AsyncTaskExecutor;

import java.util.TimerTask;


/**
 * 异步任务管理器
 *
 * @author zonevue
 */
public class AsyncSequentialExecute
{


    /**
     * 异步操作任务调度线程池，按顺序执行，只有一个线程
     */
    private final AsyncTaskExecutor executor = SpringUtils.getBean("threadPoolTaskSequentialExecutor");

    /**
     * 单例模式
     */
    private AsyncSequentialExecute(){}

    private static final AsyncSequentialExecute me = new AsyncSequentialExecute();

    public static AsyncSequentialExecute me()
    {
        return me;
    }

    /**
     * 执行任务
     *
     * @param task 任务
     */
    public void execute(final TimerTask task) {
        executor.execute(task);
    }


}
